﻿using MediatR;
using S.Archives.Domain.S.ArchivesDto;
using S.Archives.Infrstructre.InterFace;
using S.Archives.Read.Api.Application.Command;
using S.Common.Enums.Archives;

namespace S.Archives.Read.Api.Application.CommandHandlers
{
    public class GetSheepFilesAllCommandHandler : IRequestHandler<GetSheepFilesAllCommand, List<SheepFileDto>>
    {
        private readonly ISheepFileRepository sheepFile;
        public GetSheepFilesAllCommandHandler(ISheepFileRepository sheepFile)
        {
            this.sheepFile = sheepFile;
        }
        public async Task<List<SheepFileDto>> Handle(GetSheepFilesAllCommand request, CancellationToken cancellationToken)
        {
            var list =  sheepFile.GetSheepFiles().Result;
            if (request.Id > 0)
            {
                list=list.Where(x=>x.FileType==request.Id&&x.PresenceState==(PresenceStateEnum)2).ToList();
            }
            return list;
        }
    }
}
